using System;
using System.Text;

using Sce.PlayStation.Core;
using Sce.PlayStation.Core.Graphics;
using Sce.PlayStation.Core.Input;
using Sce.PlayStation.Core.Environment;

// Include 2D Physics Framework
using Sce.PlayStation.HighLevel.Physics2D;

public class BalloonScene : PhysicsScene
{
	private int currentIndex = 0;
	
    public BalloonScene()
    {
        InitScene();
    }

    public override void InitScene ()
    {
            // Create an empty simulation scene
        base.InitScene();
				
		/*sceneShapes[0] = new PhysicsShape(15.0f);
		sceneBodies[0] = new PhysicsBody(sceneShapes[0], 10.0f);
		sceneBodies[0].position = new Vector2(500, 500);
		sceneBodies[0].rotation = 0;
		sceneBodies[0].shapeIndex = 0;
		currentIndex++;
		
		sceneShapes[1] = new PhysicsShape(new Vector2(128, 32));
		sceneBodies[1] = new PhysicsBody(sceneShapes[1], PhysicsUtility.FltMax);
		sceneBodies[1].position = new Vector2(500, 100);
		sceneBodies[1].shapeIndex = 1;
		sceneBodies[1].rotation = 45;
		currentIndex++;*/
		
		numShape = 0;
		numBody = 0;
		currentIndex = 0;
		
	    this.restitutionCoeff = 0.4f;
		
		this.Gravity = new Vector2(0.0f, -98.0f);
    }
		
	public int addBody(PhysicsShape s, PhysicsBody b)
	{
		sceneShapes[currentIndex] = s;
		sceneBodies[currentIndex] = b;
		sceneBodies[currentIndex].shapeIndex = (uint)currentIndex;
		currentIndex++;
		
		this.numShape++;
		this.numBody++;
		
		return numBody - 1;
	}
	
	public void collidesWith(PhysicsBody b)
	{
		solverPair[0].GetIndexA();	
	}
	
	public void removeBody(PhysicsBody b)
	{
		int i = 0;
		foreach(PhysicsBody bod in sceneBodies)
		{
			if(bod != null)
			{
				if(bod.Equals(b))
				{
					sceneBodies[i] = null;	
					sceneShapes[i] = null;
					break;
				}
				
				i++;
			}
		}
		
		for(int j = i; j < numBody-1; j++)
		{
			sceneBodies[j-1] = sceneBodies[j];
			sceneShapes[j-1] = sceneShapes[j];
		}
		
		sceneBodies[numBody] = null;
		sceneShapes[numBody] = null;
		
		this.numShape--;
		this.numBody--;
		
		currentIndex--;
	}
	
	public int getNumberOfBodies()
	{
		return this.numBody;
	}
} 










